package com.tenbent.product.center.insures.dto;

import com.tenbent.product.base.dto.BaseDto;
import com.tenbent.product.center.insures.bo.SkuPrice;
import org.hibernate.validator.constraints.NotEmpty;

import javax.validation.constraints.Digits;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;

/**
 * Sku对应价格
 *
 * @author Randy
 *
 *         Created by ThinkPad on 2017/8/21.
 */
public class SkuPriceDto extends BaseDto {

	/** 产品ID **/
	@NotNull(message = "{product.id.not.empty}")
	private Integer productId;

	/** sku值组合，下划线（_）拼接 **/
	@NotEmpty(message = "{sku.price.risk.values.not.empty}")
	private String riskValues;

	/** 单位价格 **/
	@NotNull(message = "{sku.price.unit.price.not.empty}")
	@Digits(integer = 18, fraction = 2, message = "{sku.price.unit.price.illegal}")
	private BigDecimal unitPrice;

	/** 总价格 **/
	@NotNull(message = "{sku.price.total.price.not.empty}")
	@Digits(integer = 18, fraction = 2, message = "{sku.price.total.price.illegal}")
	private BigDecimal totalPrice;

	public SkuPriceDto() {

	}

	public SkuPriceDto(SkuPrice skuPrice) {
		super(skuPrice);
		setProductId(skuPrice.getProductId());
		setRiskValues(skuPrice.getRiskValues());
		setUnitPrice(skuPrice.getUnitPrice());
		setTotalPrice(skuPrice.getTotalPrice());
	}

	public SkuPrice transToBo() {
		SkuPrice skuPrice = new SkuPrice();
		super.transToBo(skuPrice);
		skuPrice.setProductId(this.getProductId());
		skuPrice.setRiskValues(this.getRiskValues());
		skuPrice.setUnitPrice(this.getUnitPrice());
		skuPrice.setTotalPrice(this.getTotalPrice());
		return skuPrice;
	}

	public Integer getProductId() {
		return productId;
	}

	public void setProductId(Integer productId) {
		this.productId = productId;
	}

	public String getRiskValues() {
		return riskValues;
	}

	public void setRiskValues(String riskValues) {
		this.riskValues = riskValues;
	}

	public BigDecimal getUnitPrice() {
		return unitPrice;
	}

	public void setUnitPrice(BigDecimal unitPrice) {
		this.unitPrice = unitPrice;
	}

	public BigDecimal getTotalPrice() {
		return totalPrice;
	}

	public void setTotalPrice(BigDecimal totalPrice) {
		this.totalPrice = totalPrice;
	}
}
